home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #49 (Oct 89) / DMP Source / src / PACK.c < prev    next >
Text File  |  1989-01-02  |  2KB  |  100 lines

  1. /*
  2.  * Chooser Device Package code.  Described in the Device Manager
  3.  * chapter of Inside Macintosh IV.
  4.  */
  5. /*
  6.  * Earle R. Horton.
  7.  * Wednesday, November 30, 1988
  8.  * All rights reserved.
  9.  */
  10. #include <Resources.h>
  11. #include <ToolUtils.h>
  12. #include <OSUtils.h>
  13. #include <Dialogs.h>
  14. #include <Lists.h>
  15. #define PACK
  16. #include "dmp-110.h"
  17. #include "compat.h"
  18. #define __SEG__ Main
  19. /*
  20.  * The Pascal Interface to MPW C 2.0.2 does not fully include the List Manager.
  21.  */
  22. #ifdef macintosh
  23. pascal void LGetCell(Ptr,short *,Cell,ListHandle);
  24. pascal void LSetCell(Ptr,short,Cell,ListHandle);
  25. pascal void LSetSelect(Boolean,Cell,ListHandle);
  26. #endif
  27.  
  28. pascal OSErr device(message,caller,objname,zonename,p1,p2)
  29. short   message,caller;
  30. StringPtr   objname,zonename;
  31. long    p1,p2;
  32. {
  33.     Pfg settings;
  34. #ifndef BACKWARD_COMPATIBLE
  35.     SysEnvRec World;
  36.     (void)SysEnvirons(1,&World);
  37.     if(World.systemVersion < SYSNEEDED){
  38.         (void)StopAlert(SYSVERSALERT,nil);
  39.     }
  40.     else
  41. #endif
  42.     switch(message){
  43.         case buttonMsg:
  44.             prsetup(p2);
  45.             break;
  46.         case fillListMsg:
  47.             filllist(p1);
  48.             break;
  49.         case selectMsg:
  50.             settings = (Pfg)(GetResource('HEXA',RES2ID));
  51.             pbaud = p2;
  52.             break;
  53.     }
  54.     return (noErr);
  55. }
  56. /*
  57.  * Fill the list passed to us with the names of baud rates contained
  58.  * in our 'STR#' resource.
  59.  */
  60. filllist(list)
  61. ListHandle list;
  62. {
  63.     Pfg settings;
  64.     Cell cell;
  65.     short i;
  66.     char thestring[256];
  67.     settings = (Pfg)(GetResource('HEXA',RES2ID));
  68.     (void)LAddRow(11,0,list);
  69.     for(i=0;i<11;){
  70.         SetPt(&cell,0,i++);
  71.         GetIndString(thestring,RES1ID,i);
  72.         LSetCell(&thestring[1],(short)thestring[0],cell,list);
  73.     }
  74.     SetPt(&cell,0,pbaud);
  75.     LSetSelect(0xFFFF,cell,list);
  76.     LAutoScroll(list);
  77. }
  78. /*
  79.  * prsetup() - Configure serial port.
  80.  */
  81. prsetup(button)
  82. long button;
  83. {
  84. Pfg settings;
  85.  
  86.     if ((settings = (Pfg)(GetResource('HEXA',RES2ID))) == nil)
  87.         return;
  88.     if((button & 0xFF) == 1){
  89.         if(IsMPPOpen()){                       /* Conflict! */
  90.             (void)StopAlert(ATALKALERT,nil);
  91.             return;
  92.         }
  93.         pport = 1;
  94.     }else{
  95.         pport = 0;
  96.     }
  97.     ChangedResource(settings);
  98.     WriteResource(settings);
  99. }
  100.